<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <meta name="format-detection"content="telephone=no, email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" /><!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 设置苹果工具栏颜色 -->
    <meta name=”renderer” content="ie-comp">
    <meta name=”renderer” content=”ie-stand”>
    <meta name="renderer" content="webkit"> 
    <meta name="keywords" content="耀盛中国,耀盛智投,理财产品,智选财富,耀盛智投官网"/>
    <meta name="description" content="耀盛智投为耀盛中国旗下理财产品智选平台。专注于为大众富裕阶层、精英个人、中产阶级家庭、合规机构等提供定制化资产配置咨询推荐服务，帮助客户实现财富的增值。" />
    <title>注册</title>
    <script src="../lib/js/ftSize.js"></script>
    <link rel="stylesheet" href="../lib/css/_base.css">
    <link rel="stylesheet" href="../lib/css/login.css">
    <link rel="stylesheet" href="../lib/css/publicBubb.css">
</head>
<body>
    <div class="register-page">
        <div class="mobile-page-title">注册</div>
        <section>
            <span class="login-icon">
               手机号
            </span>
            <span class="login-input" id="registerUser">
               <input type="tel" id="registerMobile" maxlength="13" onKeyPress="mobileValidation(event.keyCode||event.which)" onafterpaste="this.value=this.value.replace(/\D/g,'')" onkeyup="doSet(this)"/>
            </span>
            
        </section>
        <section>    
            <span class="login-icon">
                密码
                </span>
                <span class="login-input" id="registerPwd">
                    <input type="password" id="registerPassword">
                </span>
            
        </section>
        <section id="registerVerif">
                <span class="register-sms">
                   验证码
                </span>
                <span class="register-input" id="smsUser">
                    <input type="text" id="registerSms" maxlength="6">
                    <div class="T-getCode" id="btnSendCode">获取验证码</div>
                </span>
             
             
            </span>
        </section>
        <div class="register-agreed">
                <label id="my_protocol"><input type="checkbox"><i>✓</i>我同意</label>
                <a href="registerAgreement.html" id="register-text">《九金服会员注册协议》</a>
        </div>
        <div class="reminder-warning-tip" id="regreminder"></div>
        <div class="next-register" id="nowRegister" onClick="fnRegister()" style="display:none;"><!--  -->
            立即注册
        </div>
        <div class="next-register" id="nowRegister">
            立即注册
        </div>
        <a href="./login.html" class="already-register">立即登录</a>
    </div>
   
    <!-- 弹窗 -->
    <div class="maskWrap" style="display:none" id="registerMask">
            <div class="maskLayer">
                 <div class="maskImg"></div>
                <div class="maskTitle">注册成功</div>
    
                <div class="maskContent"></div>
                <div class="maskbtnGroup">
                    
                    <a href="attestation/index.html"> <span class="winBg"> 实名认证</span></a>
                    <a href="../home/index.html" ><span> 随便逛逛</span></a>
                    
                </div>  
            </div>
        </div>
    <script src="../lib/js/jquery.min.js"></script>  
   
    <script src="../lib/js/public-header.js"></script>  
<script>
/* 倒计时获取短信验证码 */
    var validCode=true;
    var isRegisteretion;
    var time=60;
    $('#my_protocol').click(function(){
        if($("input[type='checkbox']").is(':checked')){
            $('.next-register').eq(0).show()
            $('.next-register').eq(1).hide()
            $('#nowRegister').addClass('addLogin')
            $('#nowRegister').removeClass('reduceLogin')
        }else{
            $('.next-register').eq(1).show()
            $('.next-register').eq(0).hide()
            $('#nowRegister').addClass('reduceLogin')
            $('#nowRegister').removeClass('addLogin')
        }
    })
    
/* 获取手机号码 */
/* 手机验证码 短信验证码*/
function smsJson(mobile) {
    var json = {
        "faceCode":"common/sendSms",
        "token":"",    
        "clientInfo":"W,100,IE8",  
        "requestTime": formatDateTime(startTime),
        "body":{
            "mobile":mobile,
        }
     }
    return json;
}
//是否注册
function isRegistJson(mobile) {
    var json = {
        "faceCode":"user/registerCheck",
        "token":"",    
        "clientInfo":"W,100,IE8",  
        "requestTime": formatDateTime(startTime),
        "body":{
            "mobile":mobile,
            "flag":"3"
        }
       
     }
    return json;
}
/* 登录传递的数据 */
function loginJson(mobile,pwd) {
    var json = {
        "faceCode":"user/login",
        "token":"",
        "clientInfo":"W,100,IE8",
        "requestTime": formatDateTime(startTime),
        "body":{
            "mobile":mobile,
            "loginPwd":pwd,
            "loginType":'3',
            "imgCode":'',
            "isFlag":"2",
            "smsCode":""
        }
     }
    return json;
}
//注册信息
function RegistJson(mobile,pwd,smsCode) {
    var json = {
        "faceCode":"user/register",
        "token":"",    
        "clientInfo":"W,100,IE8",  
        "requestTime": formatDateTime(startTime),
        "body":{
            "mobile":mobile,
            "flag":"1",
            "loginPwd":pwd,
            "smsCode":smsCode,
            "regChnlId":"360，豌豆荚等",
            "regPlatform":"wap"
        }
       
     }
    return json;
}
/* 判断是否注册 */
function isRegistered(registerMobile){
     $.ajax({  
        type: "POST",
        url: httpServer+"user/registerCheck",
        headers:{
            'Access-Control-Allow-Origin':'*'
        }, 
        async:false,
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(isRegistJson(registerMobile)),
        dataType: "json",
        success: function (isMobile) {  
            isRegisteretion=isMobile 
        },
        error: function(error){  
            console.log(error,1);  
        }    
    }); 
}
    //倒计时获取短信验证码
    function getMess(){
    
        let registerMobile=$('#registerMobile').val().replace(/\s/g, "");
        
        if(registerMobile!=''){
            if(startPhone.test(registerMobile) ){
                isRegistered(registerMobile);
                if(isRegisteretion.resCode!='0'){
                    $('.reminder-warning-tip').text(isRegisteretion.errorMsg)
                }else{
                    var $code=$(this);
                    if (validCode) {
                        validCode=false;
                        var t=setInterval(function  () {
                            time--;
                            $('#btnSendCode').html(time+"秒");
                            if (time==0) {
                                clearInterval(t);
                                $('#btnSendCode').html("获取验证码");
                                validCode=true;
                            }
                        },1000)
                    }
                    $.ajax({  
                        type: "POST",
                        url: httpServer+"common/sendSms",
                        headers:{
                            'Access-Control-Allow-Origin':'*'
                        }, 
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify(smsJson(registerMobile)),
                        dataType: "json",
                        success: function (ismessAuth) {  
                            if(ismessAuth.resCode!='0'){
                                $('.reminder-warning-tip').text(ismessAuth.errorMsg)
                            }else{
                            
                                
                            }
                        },
                        error: function(error){  
                        
                        }    
                    }); 
                }
            }else{
                $('.reminder-warning-tip').text('手机号码格式有误')
            }
        }else{
            $('.reminder-warning-tip').text('请输入正确手机号')
        }
    }

    function mobileValidation(ev){//键盘事件
        if(ev == 13){
            fnRegister()
        }
    }
    /* 获取短信验证码 */
    $('#btnSendCode').on('click',function(){
        getMess()
    })
    /*  注册 */
    function fnRegister() {
        let registerMobile=$('#registerMobile').val().replace(/\s/g, "");
        let registerPwd=$('#registerPassword').val().trim();
        let registerSms=$('#registerSms').val().trim()
        if(registerMobile!=''){
            if(startPhone.test(registerMobile) ){
                if(registerPwd!=''){
                    if(payPwd.test(registerPwd)){
                        if(registerSms!=''){
                            //请求后端
                            $('#nowRegister').attr('disabled','true');
                            $.ajax({  
                                type: "POST",
                                url: httpServer+"user/register",
                                headers:{
                                    'Access-Control-Allow-Origin':'*'
                                }, 
                                async:false,
                                contentType: "application/json; charset=utf-8",
                                data: JSON.stringify(RegistJson(registerMobile,registerPwd,registerSms)),
                                dataType: "json",
                                success: function (isMobile) {  
                                    isRegister=isMobile 
                                    if(isMobile.resCode!='0'){
                                        $('.reminder-warning-tip').text(isMobile.errorMsg)
                                    }else{
                                        $('#registerMask').show()
                                        $.ajax({  
                                                type: "POST",
                                                url: httpServer+"user/login",
                                                headers:{
                                                    'Access-Control-Allow-Origin':'*'
                                                }, 
                                                contentType: "application/json; charset=utf-8",
                                                data: JSON.stringify(loginJson(registerMobile,registerPwd)),
                                                dataType: "json",
                                                success: function (loginShow) {  
                                                    if(loginShow.resCode!='0'){
                                                        $('#registerMask').hide()
                                                        $('.reminder-warning-tip').text(loginShow.errorMsg)
                                                    }else{
                                                   
                                                        let userInfo = {
                                                            avatar: loginShow.body.avatar, //头像
                                                            userId: loginShow.body.userId,//用户id
                                                            userPhone: loginShow.body.mobile,//手机号
                                                            userName: loginShow.body.userName,//用户名
                                                            certNo: loginShow.body.certNo, //身份证
                                                            bankCardNo: loginShow.body.bankCardNo, //银行卡
                                                            startTime: loginShow.body.requestTime,
                                                            faceCode: '',
                                                            token: loginShow.body.token,
                                                            clientInfo: "P,100,IE8",
                                                            riskFlag:loginShow.body.riskFlag
                                                        };
                                                        window.sessionStorage.setItem('wpuserToken', loginShow.body.token);
                                                        window.sessionStorage.setItem('wpavailableAmount', loginShow.body.availableAmount);//可用余额
                                                        window.sessionStorage.setItem('wpcertFlag', loginShow.body.certFlag) //认证标志 1认证2未认证
                                                        window.sessionStorage.setItem("wpuserInfo", JSON.stringify(userInfo)); //是否登录
                                                        window.sessionStorage.setItem('wpriskFlag', loginShow.body.riskFlag)// 1评测，2:未评测
                                                    }
                                            },
                                                error: function(error){  
                                                    console.log(error);  
                                                    }    
                                            });  
                                    }
                                
                                },
                                error: function(error){  
                                    console.log(error,1);  
                                }    
                            }); 
                           
                        }else{
                            $('.reminder-warning-tip').text('请输入短信验证码！')
                        }
                    }else{
                        $('.reminder-warning-tip').text('请输入6~16位字母数字组合!')
                    }
                }else{
                    $('.reminder-warning-tip').text('请输入6~16位字母数字组合!') 
                }
            }else{
                $('.reminder-warning-tip').text('请输入正确的11位手机号码')
            } 
        }else{
            $('.reminder-warning-tip').text('请输入正确的11位手机号码')
            blurRegister()
        } 
    }
   //默认登录 

/* 手机号失去焦点 */
    $('#registerMobile').blur(function(){
        blurRegister()
    })  
    /* 登录密码失去焦点 */
    $('#registerPassword').blur(function(){
        blurRegister()
    })
    /* 短信验证码失去焦点 */
    $('#registerSms').blur(function(){
        $('#registerVerif').css('border-bottom','1px solid #EBEBEB')
       
    })
    /* 手机号获取焦点 */
    $('#registerMobile').focus(function(){
       
        $('.reminder-warning-tip').text(' ')
        if($('#registerUser').attr('class')!='login-inputActive'){
            $('#registerUser').addClass('login-inputActive')
        }
    });
    /* 登录密码获取焦点 */
    $('#registerPassword').focus(function(){
        
        $('.reminder-warning-tip').text(' ')
        if($('#registerPwd').attr('class')!='login-inputActive'){
            $('#registerPwd').addClass('login-inputActive')
        }
    }); /* 短信验证码获取焦点 */
    $('#registerSms').focus(function(){
        $('.reminder-warning-tip').text(' ')
        $('#registerVerif').css('border-bottom','1px solid #AE915F')
       
    })
/* 登录密码失去焦点 */ 
    function blurRegister(){
        if($('#registerUser').attr('class').indexOf('login-inputActive')!=-1 ){
            $('#registerUser').removeClass('login-inputActive')
        }else if($('#registerPwd').attr('class').indexOf('login-inputActive')!=-1){
            $('#registerPwd').removeClass('login-inputActive')
        }
    }
    function focusInput(){
        if($('#registerUser').attr('class')!='login-inputActive'){
            $('#registerUser').addClass('login-inputActive')
        }else if($('#registerPwd').attr('class')!='login-inputActive'){
            $('#registerPwd').addClass('login-inputActive')
        }
    }

</script>
</body>
</html>